package com.tyl.bk;

import java.util.concurrent.ArrayBlockingQueue;
import java.util.concurrent.BlockingQueue;

/**
 *等待，阻塞
 **/
//队列
public class BlockingQueueTest3 {

    public static void main(String[] args) throws InterruptedException {
        BlockingQueue blockingQueue= new ArrayBlockingQueue<>(3);
        blockingQueue.put("a");
        blockingQueue.put("b");
        blockingQueue.put("c");
       // blockingQueue.put("d");//位置满了会一直阻塞
        System.out.println("=============================");
        System.out.println(blockingQueue.take());
        System.out.println(blockingQueue.take());
        System.out.println(blockingQueue.take());
        System.out.println(blockingQueue.take());//没有元素了会一直等待阻塞
    }
}

